<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Model View Controller | Rho Framework Docs</title>
<meta name="description" value="Model View Controller - Documentation for the Rho PHP Framework" />
<meta name="keywords" value="rho, framework, php, docs, documentation, help, examples" />
<link href="docs.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<!-- header -->
<div id="byline">ρ Rho Framework Documentation</div>
<h1>Model View Controller</h1>

<p>Rho uses the <abbr title="Model View Controller">MVC</abbr> design pattern, as it fits well for
web applications, seperates business logic from presentation, encourages code-reuse, and helps prevents 
spagetti code.</p>

<h2>Undertanding MVC</h2>
<img src="ModelViewControllerDiagram.png" width="321" height="151"
title="Source: Fred Bradstadt. Public Domain" 
alt="Model View Controller Diagram" />
<p>In MVC, code is split into 3 main parts.</p>

<div class="note">Note that in a web application, the architecture is slightly
different to that of a GUI application, mainly due to HTTP being stateless.</div>
<dl>
  <dt><strong>Controller</strong></dt>
  <dd>This is receives user input, interacts with the model and returns output to the view. 
  <p>In Rho, this is the code that receives the browser request,
  processs it, and returns the web page/RSS feed/etc.</p></dd>
  <dt><strong>Model</strong></dt>
  <dd>This is responsable for data storage and retrival.
  <p>In Rho, as in other web apps, the model is often using a table in a database for storage,
  though this must not be the case.  The model is resposible for how the data is stored/retrieved and
  enforcing business logic.  The actual implementation is transparent to the controller.</p></dd>
  <dt><strong>View</strong></dt>
  <dd>This is the presentation of the data.
  <p>In Rho, this a web page (or RSS Feed, etc.) template which is loaded with data from the model
  by the controller.  May contain presentation logic (but not business logic).</p></dd>
</dl>
<p>In Rho, the user always interacts with the controller, never with the view or model directly,
and models and views only interact with the controller, not with each other.</p>


<div class="next"><a href="naming.html">Naming Conventions &gt;&gt;</a></div>

<div id="footer"><p><a href="index.html">Contents</a></p>
<a href="http://code.google.com/p/rho/">Rho Framework Home</a></div>

</body>
</html>